/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import entities.OperationBancaire;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Gael
 */
@Stateless
@LocalBean
public class GestionnaireOperation {
    @PersistenceContext(unitName = "ARTP3-ejbPU")
    private EntityManager em;

    public List<OperationBancaire> getAllOperations() {
          Query query = em.createNamedQuery("OperationBancaire.findAll");
        return query.getResultList();
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    public void persist(Object object) {
        em.persist(object);
        em.flush();
    }
    public void creerOperation(OperationBancaire ob){
        em.persist(ob);
        em.flush();
    }
    public OperationBancaire update(OperationBancaire ob) {
        OperationBancaire o = em.merge(ob);
        em.flush();
        return o;
    }
}
